<!DOCTYPE html>
<html class="client-nojs vector-feature-night-mode-disabled vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-1 vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref-1 vector-feature-appearance-pinned-clientpref-1 vector-sticky-header-enabled" lang="en" dir="ltr"><head>
<meta charset="UTF-8">
<title>Segmentation fault</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="canonical" href="https://en.wikipedia.org/wiki/Segmentation_fault"> <link href="./mw/ext.cite.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/ext.pygments.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.icons.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.search.codex.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/user.styles.css" rel="stylesheet" type="text/css">
<meta name="ResourceLoaderDynamicStyles" content="">
<link rel="stylesheet" type="text/css" href="./mw/site.styles.css">
<link rel="stylesheet" type="text/css" href="./mw/noscript.css">
<link rel="stylesheet" type="text/css" href="./footer.css">
<link rel="stylesheet" type="text/css" href="./vector-2022.css">
</head>
<body class="skin--responsive skin-vector skin-vector-search-vue mediawiki ltr sitedir-ltr mw-hide-empty-elt ns-0 ns-subject page-Segmentation_fault rootpage-Segmentation_fault skin-vector-2022 action-view">
<div class="mw-page-container">
<div class="mw-page-container-inner">
<div class="mw-content-container">
<main id="content" class="mw-body">
<header class="mw-body-header vector-page-titlebar">
<h1 id="firstHeading" class="firstHeading mw-first-heading">
<span id="openzim-page-title" class="mw-page-title-main"><span class="mw-page-title-main">Segmentation fault</span></span>
</h1>
</header>
<a id="top"></a>
<div id="bodyContent" class="vector-body ve-init-mw-desktopArticleTarget-targetContainer" aria-labelledby="firstHeading" data-mw-ve-target-container="">
<div id="mw-content-text" class="mw-body-content mw-content-ltr" lang="en" dir="ltr"><div class="mw-content-ltr mw-parser-output" lang="en" dir="ltr">
<style data-mw-deduplicate="TemplateStyles:r1236090951">
/* start https://en.wikipedia.org/ */
.mw-parser-output .hatnote{font-style:italic}.mw-parser-output div.hatnote{padding-left:1.6em;margin-bottom:0.5em}.mw-parser-output .hatnote i{font-style:normal}.mw-parser-output .hatnote+link+.hatnote{margin-top:-0.5em}@media print{body.ns-0 .mw-parser-output .hatnote{display:none!important}}
/* end https://en.wikipedia.org/ */
</style><div role="note" class="hatnote navigation-not-searchable">"Segfault" redirects here. For the website, see <a href="Segfault_(website)" title="Segfault (website)">Segfault (website)</a>.</div>
<style data-mw-deduplicate="TemplateStyles:r1305433154">
/* start https://en.wikipedia.org/ */
.mw-parser-output .ambox{border:1px solid #a2a9b1;border-left:10px solid #36c;background-color:#fbfbfb;box-sizing:border-box}.mw-parser-output .ambox+link+.ambox,.mw-parser-output .ambox+link+style+.ambox,.mw-parser-output .ambox+link+link+.ambox,.mw-parser-output .ambox+.mw-empty-elt+link+.ambox,.mw-parser-output .ambox+.mw-empty-elt+link+style+.ambox,.mw-parser-output .ambox+.mw-empty-elt+link+link+.ambox{margin-top:-1px}html body.mediawiki .mw-parser-output .ambox.mbox-small-left{margin:4px 1em 4px 0;overflow:hidden;width:238px;border-collapse:collapse;font-size:88%;line-height:1.25em}.mw-parser-output .ambox-speedy{border-left:10px solid #b32424;background-color:#fee7e6}.mw-parser-output .ambox-delete{border-left:10px solid #b32424}.mw-parser-output .ambox-content{border-left:10px solid #f28500}.mw-parser-output .ambox-style{border-left:10px solid #fc3}.mw-parser-output .ambox-move{border-left:10px solid #9932cc}.mw-parser-output .ambox-protection{border-left:10px solid #a2a9b1}.mw-parser-output .ambox .mbox-text{border:none;padding:0.25em 0.5em;width:100%}.mw-parser-output .ambox .mbox-image{border:none;padding:2px 0 2px 0.5em;text-align:center}.mw-parser-output .ambox .mbox-imageright{border:none;padding:2px 0.5em 2px 0;text-align:center}.mw-parser-output .ambox .mbox-empty-cell{border:none;padding:0;width:1px}.mw-parser-output .ambox .mbox-image-div{width:52px}@media(min-width:720px){.mw-parser-output .ambox{margin:0 10%}}@media print{body.ns-0 .mw-parser-output .ambox{display:none!important}}
/* end https://en.wikipedia.org/ */
</style>
<p>In <a href="Computing" title="Computing">computing</a>, a <b>segmentation fault</b> (often shortened to <b>segfault</b>) or <b>access violation</b> is a <a href="Interrupt" title="Interrupt">failure condition</a> raised by hardware with <a href="Memory_protection" title="Memory protection">memory protection</a>, notifying an <a href="Operating_system" title="Operating system">operating system</a> (OS) that the software has attempted to access a restricted area of memory (a memory access violation). On standard <a href="X86" title="X86">x86</a> computers, this is a form of <a href="General_protection_fault" title="General protection fault">general protection fault</a>. The operating system <a href="Kernel_(operating_system)" title="Kernel (operating system)">kernel</a> will, in response, usually perform some corrective action, generally passing the fault on to the offending <a href="Process_(computing)" title="Process (computing)">process</a> by sending the process a <a href="Signal_(IPC)" title="Signal (IPC)">signal</a>. Processes can in some cases install a custom signal handler, allowing them to recover on their own,<sup id="cite_ref-Peter_Van_der_Linden_1-0" class="reference"><a href="#cite_note-Peter_Van_der_Linden-1"><span class="cite-bracket">[</span>1<span class="cite-bracket">]</span></a></sup> but otherwise the OS default signal handler is used, generally causing <a href="Abnormal_termination" class="mw-redirect" title="Abnormal termination">abnormal termination</a> of the process (a program <a href="Crash_(computing)" title="Crash (computing)">crash</a>), and sometimes a <a href="Core_dump" title="Core dump">core dump</a>.
</p><p>Segmentation faults are a common class of error in programs written in languages like <a href="C_(programming_language)" title="C (programming language)">C</a> that provide low-level memory access and few to no safety checks. They arise primarily due to errors in use of <a href="Pointer_(computer_programming)" title="Pointer (computer programming)">pointers</a> for <a href="Virtual_memory" title="Virtual memory">virtual memory</a> addressing, particularly illegal access. Another type of memory access error is a <a href="Bus_error" title="Bus error">bus error</a>, which also has various causes, but is today much rarer; these occur primarily due to incorrect <i>physical</i> memory addressing, or due to misaligned memory access – these are memory references that the hardware <i>cannot</i> address, rather than references that a process is not <i>allowed</i> to address.
</p><p>Many programming languages have mechanisms designed to avoid segmentation faults and improve memory safety. For example, <a href="Rust_(programming_language)" title="Rust (programming language)">Rust</a> employs an ownership-based<sup id="cite_ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">[</span>2<span class="cite-bracket">]</span></a></sup> model to ensure memory safety.<sup id="cite_ref-3" class="reference"><a href="#cite_note-3"><span class="cite-bracket">[</span>3<span class="cite-bracket">]</span></a></sup> Other languages, such as <a href="Lisp_(programming_language)" title="Lisp (programming language)">Lisp</a> and <a href="Java_(programming_language)" title="Java (programming language)">Java</a>, employ <a href="Garbage_collection_(computer_science)" title="Garbage collection (computer science)">garbage collection</a>,<sup id="cite_ref-4" class="reference"><a href="#cite_note-4"><span class="cite-bracket">[</span>4<span class="cite-bracket">]</span></a></sup> which avoids certain classes of memory errors that could lead to segmentation faults.<sup id="cite_ref-5" class="reference"><a href="#cite_note-5"><span class="cite-bracket">[</span>5<span class="cite-bracket">]</span></a></sup>
</p>
<meta property="mw:PageProp/toc">
<div class="mw-heading mw-heading2"><h2 id="Overview">Overview</h2></div>
<p>A segmentation fault occurs when a program attempts to access a <a href="Computer_memory" title="Computer memory">memory</a> location that it is not allowed to access, or attempts to access a memory location in a way that is not allowed (for example, attempting to write to a <a href="Read-only_memory" title="Read-only memory">read-only</a> location, or to overwrite part of the <a href="Operating_system" title="Operating system">operating system</a>).
</p><p>The term "segmentation" has various uses in computing; in the context of "segmentation fault", it refers to the address space of a <i>program.</i><sup id="cite_ref-6" class="reference"><a href="#cite_note-6"><span class="cite-bracket">[</span>6<span class="cite-bracket">]</span></a></sup> With memory protection, only the program's own address space is readable, and of this, only the <a href="Call_stack" title="Call stack">stack</a> and the read/write portion of the <a href="Data_segment" title="Data segment">data segment</a> of a program are writable, while read-only data allocated in the const segment and the <a href="Code_segment" title="Code segment">code segment</a> are not writable. Thus attempting to read outside of the program's address space, or writing to a read-only segment of the address space, results in a segmentation fault, hence the name.
</p><p>On systems using hardware <a href="Memory_segmentation" title="Memory segmentation">memory segmentation</a> to provide <a href="Virtual_memory" title="Virtual memory">virtual memory</a>, a segmentation fault occurs when the hardware detects an attempt to refer to a non-existent segment, or to refer to a location outside the bounds of a segment, or to refer to a location in a fashion not allowed by the permissions granted for that segment. On systems using only <a href="Paging" class="mw-redirect" title="Paging">paging</a>, an <a href="Invalid_page_fault" class="mw-redirect" title="Invalid page fault">invalid page fault</a> generally leads to a segmentation fault, and segmentation faults and page faults are both faults raised by the <a href="Virtual_memory" title="Virtual memory">virtual memory</a> management system. Segmentation faults can also occur independently of page faults: illegal access to a valid page is a segmentation fault, but not an invalid page fault, and segmentation faults can occur in the middle of a page (hence no page fault), for example in a <a href="Buffer_overflow" title="Buffer overflow">buffer overflow</a> that stays within a page but illegally overwrites memory.
</p><p>At the hardware level, the fault is initially raised by the <a href="Memory_management_unit" title="Memory management unit">memory management unit</a> (MMU) on illegal access (if the referenced memory exists), as part of its memory protection feature, or an invalid page fault (if the referenced memory does not exist). If the problem is not an invalid logical address but instead an invalid physical address, a <a href="Bus_error" title="Bus error">bus error</a> is raised instead, though these are not always distinguished.
</p><p>At the operating system level, this fault is caught and a signal is passed on to the offending process, activating the process's handler for that signal. Different operating systems have different signal names to indicate that a segmentation fault has occurred. On <a href="Unix-like" title="Unix-like">Unix-like</a> operating systems, a signal called SIGSEGV (abbreviated from <i>segmentation violation</i>) is sent to the offending process. On <a href="Microsoft_Windows" title="Microsoft Windows">Microsoft Windows</a>, the offending process receives a STATUS_ACCESS_VIOLATION <a href="Exception_handling" title="Exception handling">exception</a>.
</p>
<div class="mw-heading mw-heading2"><h2 id="Causes">Causes</h2></div>
<p>The conditions under which segmentation violations occur and how they manifest themselves are specific to hardware and the operating system: different hardware raises different faults for given conditions, and different operating systems convert these to different signals that are passed on to processes. The proximate cause is a memory access violation, while the underlying cause is generally a <a href="Software_bug" title="Software bug">software bug</a> of some sort. Determining the <a href="Root_cause_analysis" title="Root cause analysis">root cause</a> – <a href="Debugging" title="Debugging">debugging</a> the bug – can be simple in some cases, where the program will consistently cause a segmentation fault (e.g., dereferencing a <a href="Null_pointer" title="Null pointer">null pointer</a>), while in other cases the bug can be difficult to reproduce and depend on memory allocation on each run (e.g., dereferencing a <a href="Dangling_pointer" title="Dangling pointer">dangling pointer</a>).
</p><p>The following are some typical causes of a segmentation fault:
</p>
<ul><li>Attempting to access a nonexistent memory address (outside process's address space)</li>
<li>Attempting to access memory the program does not have rights to (such as kernel structures in process context)</li>
<li>Attempting to write read-only memory (such as code segment)</li></ul>
<p>These in turn are often caused by programming errors that result in invalid memory access:
</p>
<ul><li>Dereferencing a <a href="Null_pointer" title="Null pointer">null pointer</a>, which usually points to an address that's not part of the process's address space</li>
<li>Dereferencing or assigning to an uninitialized pointer (<a href="Wild_pointer" class="mw-redirect" title="Wild pointer">wild pointer</a>, which points to a random memory address)</li>
<li>Dereferencing or assigning to a freed pointer (<a href="Dangling_pointer" title="Dangling pointer">dangling pointer</a>, which points to memory that has been freed/deallocated/deleted)</li>
<li>A <a href="Buffer_overflow" title="Buffer overflow">buffer overflow</a></li>
<li>A <a href="Stack_overflow" title="Stack overflow">stack overflow</a></li>
<li>Attempting to execute a program that does not compile correctly. (Some compilers will output an <a href="Executable_file" class="mw-redirect" title="Executable file">executable file</a> despite the presence of compile-time errors.)</li></ul>
<p>In C code, segmentation faults most often occur because of errors in pointer use, particularly in <a href="C_dynamic_memory_allocation" title="C dynamic memory allocation">C dynamic memory allocation</a>. Dereferencing a null pointer, which results in <a href="Undefined_behavior" title="Undefined behavior">undefined behavior</a>, will usually cause a segmentation fault. This is because a null pointer cannot be a valid memory address. On the other hand, wild pointers and dangling pointers point to memory that may or may not exist, and may or may not be readable or writable, and thus can result in transient bugs. For example:
</p>
<div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span class="kt">char</span><span class="w"> </span><span class="o">*</span><span class="n">p1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">NULL</span><span class="p">;</span><span class="w"> </span><span class="c1">// Null pointer</span>
<span class="kt">char</span><span class="w"> </span><span class="o">*</span><span class="n">p2</span><span class="p">;</span><span class="w"> </span><span class="c1">// Wild pointer: not initialized at all.</span>
<span class="kt">char</span><span class="w"> </span><span class="o">*</span><span class="n">p3</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">malloc</span><span class="p">(</span><span class="mi">10</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="k">sizeof</span><span class="p">(</span><span class="kt">char</span><span class="p">));</span><span class="w"> </span><span class="c1">// Initialized pointer to allocated memory</span>
<span class="w"> </span><span class="c1">// (assuming malloc did not fail)</span>
<span class="n">free</span><span class="p">(</span><span class="n">p3</span><span class="p">);</span><span class="w"> </span><span class="c1">// p3 is now a dangling pointer, as memory has been freed</span>
</pre></div>
<p>Dereferencing any of these variables could cause a segmentation fault: dereferencing the null pointer generally will cause a segfault, while reading from the wild pointer may instead result in random data but no segfault, and reading from the dangling pointer may result in valid data for a while, and then random data as it is overwritten.
</p>
<div class="mw-heading mw-heading2"><h2 id="Handling">Handling</h2></div>
<p>The default action for a segmentation fault or bus error is <a href="Abnormal_termination" class="mw-redirect" title="Abnormal termination">abnormal termination</a> of the process that triggered it. A <a href="Core_file" class="mw-redirect" title="Core file">core file</a> may be generated to aid debugging, and other platform-dependent actions may also be performed. For example, <a href="Linux" title="Linux">Linux</a> systems using the grsecurity patch may log SIGSEGV signals in order to monitor for possible intrusion attempts using <a href="Buffer_overflow" title="Buffer overflow">buffer overflows</a>.
</p><p>On some systems, like Linux and Windows, it is possible for the program itself to handle a segmentation fault.<sup id="cite_ref-7" class="reference"><a href="#cite_note-7"><span class="cite-bracket">[</span>7<span class="cite-bracket">]</span></a></sup> Depending on the architecture and operating system, the running program can not only handle the event but may extract some information about its state like getting a <a href="Stack_trace" title="Stack trace">stack trace</a>, <a href="Processor_register" title="Processor register">processor register</a> values, the line of the source code when it was triggered, memory address that was invalidly accessed<sup id="cite_ref-8" class="reference"><a href="#cite_note-8"><span class="cite-bracket">[</span>8<span class="cite-bracket">]</span></a></sup> and whether the action was a read or a write.<sup id="cite_ref-9" class="reference"><a href="#cite_note-9"><span class="cite-bracket">[</span>9<span class="cite-bracket">]</span></a></sup>
</p><p>Although a segmentation fault generally means that the program has a bug that needs fixing, it is also possible to intentionally cause such failure for the purposes of testing, debugging and also to emulate platforms where direct access to memory is needed. On the latter case, the system must be able to allow the program to run even after the fault occurs. In this case, when the system allows, it is possible to handle the event and increment the processor program counter to "jump" over the failing instruction to continue the execution.<sup id="cite_ref-10" class="reference"><a href="#cite_note-10"><span class="cite-bracket">[</span>10<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading2"><h2 id="Examples">Examples</h2></div>
<div class="mw-heading mw-heading3"><h3 id="Writing_to_read-only_memory">Writing to read-only memory</h3></div>
<p>Writing to read-only memory raises a segmentation fault. At the level of code errors, this occurs when the program writes to part of its own <a href="Code_segment" title="Code segment">code segment</a> or the read-only portion of the <a href="Data_segment" title="Data segment">data segment</a>, as these are loaded by the OS into read-only memory.
</p><p>Here is an example of <a href="ANSI_C" title="ANSI C">ANSI C</a> code that will generally cause a segmentation fault on platforms with memory protection. It attempts to modify a <a href="String_literal" title="String literal">string literal</a>, which is undefined behavior according to the ANSI C standard. Most <a href="Compiler" title="Compiler">compilers</a> will not catch this at compile time, and instead compile this to executable code that will crash:
</p>
<div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span class="kt">int</span><span class="w"> </span><span class="nf">main</span><span class="p">(</span><span class="kt">void</span><span class="p">)</span>
<span class="p">{</span>
<span class="w"> </span><span class="kt">char</span><span class="w"> </span><span class="o">*</span><span class="n">s</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">"hello world"</span><span class="p">;</span>
<span class="w"> </span><span class="o">*</span><span class="n">s</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="sc">'H'</span><span class="p">;</span>
<span class="p">}</span>
</pre></div>
<p>When the program containing this code is compiled, the string "hello world" is placed in the <a href="Rodata" class="mw-redirect" title="Rodata">rodata</a> section of the program <a href="Executable_file" class="mw-redirect" title="Executable file">executable file</a>: the read-only section of the <a href="Data_segment" title="Data segment">data segment</a>. When loaded, the operating system places it with other strings and <a href="Constant_(programming)" class="mw-redirect" title="Constant (programming)">constant</a> data in a read-only segment of memory. When executed, a variable, <i>s</i>, is set to point to the string's location, and an attempt is made to write an <i>H</i> character through the variable into the memory, causing a segmentation fault. Compiling such a program with a compiler that does not check for the assignment of read-only locations at compile time, and running it on a Unix-like operating system produces the following <a href="Runtime_error" class="mw-redirect" title="Runtime error">runtime error</a>:
</p>
<div class="mw-highlight mw-highlight-lang-console mw-content-ltr" dir="ltr"><pre><span class="gp">$ </span>gcc<span class="w"> </span>segfault.c<span class="w"> </span>-g<span class="w"> </span>-o<span class="w"> </span>segfault
<span class="gp">$ </span>./segfault
<span class="go">Segmentation fault</span>
</pre></div>
<p><a href="Backtrace" class="mw-redirect" title="Backtrace">Backtrace</a> of the core file from <a href="GDB" class="mw-redirect" title="GDB">GDB</a>:
</p>
<div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span class="n">Program</span><span class="w"> </span><span class="n">received</span><span class="w"> </span><span class="n">signal</span><span class="w"> </span><span class="n">SIGSEGV</span><span class="p">,</span><span class="w"> </span><span class="n">Segmentation</span><span class="w"> </span><span class="n">fault</span><span class="p">.</span>
<span class="mh">0x1c0005c2</span><span class="w"> </span><span class="n">in</span><span class="w"> </span><span class="n">main</span><span class="w"> </span><span class="p">()</span><span class="w"> </span><span class="n">at</span><span class="w"> </span><span class="n">segfault</span><span class="p">.</span><span class="n">c</span><span class="o">:</span><span class="mi">6</span>
<span class="mi">6</span><span class="w"> </span><span class="o">*</span><span class="n">s</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="sc">'H'</span><span class="p">;</span>
</pre></div>
<p>This code can be corrected by using an array instead of a character pointer, as this allocates memory on stack and initializes it to the value of the string literal:
</p>
<div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span class="kt">char</span><span class="w"> </span><span class="n">s</span><span class="p">[]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">"hello world"</span><span class="p">;</span>
<span class="n">s</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="sc">'H'</span><span class="p">;</span><span class="w"> </span><span class="c1">// equivalently, *s = 'H';</span>
</pre></div>
<p>Even though string literals should not be modified (this has undefined behavior in the C standard), in C they are of <code>static char []</code> type,<sup id="cite_ref-11" class="reference"><a href="#cite_note-11"><span class="cite-bracket">[</span>11<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-12" class="reference"><a href="#cite_note-12"><span class="cite-bracket">[</span>12<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-13" class="reference"><a href="#cite_note-13"><span class="cite-bracket">[</span>13<span class="cite-bracket">]</span></a></sup> so there is no implicit conversion in the original code (which points a <code>char *</code> at that array), while in C++ they are of <code>static const char []</code> type, and thus there is an implicit conversion, so compilers will generally catch this particular error.
</p>
<div class="mw-heading mw-heading3"><h3 id="Null_pointer_dereference">Null pointer dereference</h3></div>
<p>In C and C-like languages, <a href="Null_pointer" title="Null pointer">null pointers</a> are used to mean "pointer to no object" and as an error indicator, and <a href="Dereferencing" class="mw-redirect" title="Dereferencing">dereferencing</a> a null pointer (a read or write through a null pointer) is a very common program error. The C standard does not say that the null pointer is the same as the pointer to <a href="Memory_address" title="Memory address">memory address</a> 0, though that may be the case in practice. Most operating systems map the null pointer's address such that accessing it causes a segmentation fault. This behavior is not guaranteed by the C standard. Dereferencing a null pointer is <a href="Undefined_behavior" title="Undefined behavior">undefined behavior</a> in C, and a conforming implementation is allowed to assume that any pointer that is dereferenced is not null.
</p>
<div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span class="kt">int</span><span class="w"> </span><span class="o">*</span><span class="n">ptr</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">NULL</span><span class="p">;</span>
<span class="n">printf</span><span class="p">(</span><span class="s">"%d"</span><span class="p">,</span><span class="w"> </span><span class="o">*</span><span class="n">ptr</span><span class="p">);</span>
</pre></div>
<p>This sample code creates a <a href="Null_pointer" title="Null pointer">null pointer</a>, and then tries to access its value (read the value). Doing so causes a segmentation fault at runtime on many operating systems.
</p><p>Dereferencing a null pointer and then assigning to it (writing a value to a non-existent target) also usually causes a segmentation fault:
</p>
<div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span class="kt">int</span><span class="w"> </span><span class="o">*</span><span class="n">ptr</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">NULL</span><span class="p">;</span>
<span class="o">*</span><span class="n">ptr</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="p">;</span>
</pre></div>
<p>The following code includes a null pointer dereference, but when compiled will often not result in a segmentation fault, as the value is unused and thus the dereference will often be optimized away by <a href="Dead_code_elimination" class="mw-redirect" title="Dead code elimination">dead code elimination</a>:
</p>
<div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span class="kt">int</span><span class="w"> </span><span class="o">*</span><span class="n">ptr</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">NULL</span><span class="p">;</span>
<span class="o">*</span><span class="n">ptr</span><span class="p">;</span>
</pre></div>
<div class="mw-heading mw-heading3"><h3 id="Buffer_overflow">Buffer overflow</h3></div>
<div role="note" class="hatnote navigation-not-searchable">Main article: <a href="Buffer_overflow" title="Buffer overflow">Buffer overflow</a></div>
<p>The following code accesses the character array <code>s</code> beyond its upper boundary. Depending on the compiler and the processor, this may result in a segmentation fault.
</p>
<div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span class="kt">char</span><span class="w"> </span><span class="n">s</span><span class="p">[]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">"hello world"</span><span class="p">;</span>
<span class="kt">char</span><span class="w"> </span><span class="n">c</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">s</span><span class="p">[</span><span class="mi">20</span><span class="p">];</span>
</pre></div>
<div class="mw-heading mw-heading3"><h3 id="Stack_overflow">Stack overflow</h3></div>
<div role="note" class="hatnote navigation-not-searchable">Main article: <a href="Stack_overflow" title="Stack overflow">Stack overflow</a></div>
<p>Another example is <a href="Recursion" title="Recursion">recursion</a> without a base case:
</p>
<div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span class="kt">int</span><span class="w"> </span><span class="nf">main</span><span class="p">(</span><span class="kt">void</span><span class="p">)</span>
<span class="p">{</span>
<span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="n">main</span><span class="p">();</span>
<span class="p">}</span>
</pre></div>
<p>which causes the <a href="Stack_overflow" title="Stack overflow">stack to overflow</a> which results in a segmentation fault.<sup id="cite_ref-14" class="reference"><a href="#cite_note-14"><span class="cite-bracket">[</span>14<span class="cite-bracket">]</span></a></sup> Infinite recursion may not necessarily result in a stack overflow depending on the language, optimizations performed by the compiler and the exact structure of a code. In this case, the behavior of unreachable code (the return statement) is undefined, so the compiler can eliminate it and use a <a href="Tail_call" title="Tail call">tail call</a> optimization that might result in no stack usage. Other optimizations could include translating the recursion into iteration, which given the structure of the example function would result in the program running forever, while probably not overflowing its stack.
</p>
<div class="mw-heading mw-heading2"><h2 id="See_also">See also</h2></div>
<ul><li><a href="General_protection_fault" title="General protection fault">General protection fault</a></li>
<li><a href="Storage_violation" title="Storage violation">Storage violation</a></li>
<li><a href="Guru_Meditation" title="Guru Meditation">Guru Meditation</a></li></ul>
<div class="mw-heading mw-heading2"><h2 id="References">References</h2></div>
<style data-mw-deduplicate="TemplateStyles:r1239543626">
/* start https://en.wikipedia.org/ */
.mw-parser-output .reflist{margin-bottom:0.5em;list-style-type:decimal}@media screen{.mw-parser-output .reflist{font-size:90%}}.mw-parser-output .reflist .references{font-size:100%;margin-bottom:0;list-style-type:inherit}.mw-parser-output .reflist-columns-2{column-width:30em}.mw-parser-output .reflist-columns-3{column-width:25em}.mw-parser-output .reflist-columns{margin-top:0.3em}.mw-parser-output .reflist-columns ol{margin-top:0}.mw-parser-output .reflist-columns li{page-break-inside:avoid;break-inside:avoid-column}.mw-parser-output .reflist-upper-alpha{list-style-type:upper-alpha}.mw-parser-output .reflist-upper-roman{list-style-type:upper-roman}.mw-parser-output .reflist-lower-alpha{list-style-type:lower-alpha}.mw-parser-output .reflist-lower-greek{list-style-type:lower-greek}.mw-parser-output .reflist-lower-roman{list-style-type:lower-roman}
/* end https://en.wikipedia.org/ */
</style><div class="reflist">
<div class="mw-references-wrap mw-references-columns"><ol class="references">
<li id="cite_note-Peter_Van_der_Linden-1"><span class="mw-cite-backlink"><b><a href="#cite_ref-Peter_Van_der_Linden_1-0">^</a></b></span> <span class="reference-text"><i>Expert C programming: deep C secrets</i> By Peter Van der Linden, page 188</span>
</li>
<li id="cite_note-2"><span class="mw-cite-backlink"><b><a href="#cite_ref-2">^</a></b></span> <span class="reference-text"><style data-mw-deduplicate="TemplateStyles:r1238218222">
/* start https://en.wikipedia.org/ */
.mw-parser-output cite.citation{font-style:inherit;word-wrap:break-word}.mw-parser-output .citation q{quotes:"\"""\"""'""'"}.mw-parser-output .citation:target{background-color:rgba(0,127,255,0.133)}.mw-parser-output .id-lock-free.id-lock-free a{background:url("./mw/Lock-green.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-limited.id-lock-limited a,.mw-parser-output .id-lock-registration.id-lock-registration a{background:url("./mw/Lock-gray-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-subscription.id-lock-subscription a{background:url("./mw/Lock-red-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .cs1-ws-icon a{background:url("./mw/Wikisource-logo.svg")right 0.1em center/12px no-repeat}body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-free a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-limited a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-registration a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-subscription a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .cs1-ws-icon a{background-size:contain;padding:0 1em 0 0}.mw-parser-output .cs1-code{color:inherit;background:inherit;border:none;padding:inherit}.mw-parser-output .cs1-hidden-error{display:none;color:var(--color-error,#d33)}.mw-parser-output .cs1-visible-error{color:var(--color-error,#d33)}.mw-parser-output .cs1-maint{display:none;color:#085;margin-left:0.3em}.mw-parser-output .cs1-kern-left{padding-left:0.2em}.mw-parser-output .cs1-kern-right{padding-right:0.2em}.mw-parser-output .citation .mw-selflink{font-weight:inherit}@media screen{.mw-parser-output .cs1-format{font-size:95%}html.skin-theme-clientpref-night .mw-parser-output .cs1-maint{color:#18911f}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .cs1-maint{color:#18911f}}
/* end https://en.wikipedia.org/ */
</style><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://doc.rust-lang.org/book/ch04-01-what-is-ownership.html">"The Rust Programming Language - Ownership"</a>.</cite></span>
</li>
<li id="cite_note-3"><span class="mw-cite-backlink"><b><a href="#cite_ref-3">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://blog.rust-lang.org/2015/04/10/Fearless-Concurrency.html">"Fearless Concurrency with Rust - The Rust Programming Language Blog"</a>.</cite></span>
</li>
<li id="cite_note-4"><span class="mw-cite-backlink"><b><a href="#cite_ref-4">^</a></b></span> <span class="reference-text"><cite id="CITEREFMcCarthy1960" class="citation journal cs1"><a href="John_McCarthy_(computer_scientist)" title="John McCarthy (computer scientist)">McCarthy, John</a> (April 1960). <a rel="nofollow" class="external text" href="http://www-formal.stanford.edu/jmc/recursive.html">"Recursive functions of symbolic expressions and their computation by machine, Part I"</a>. <i><a href="Communications_of_the_ACM" title="Communications of the ACM">Communications of the ACM</a></i>. <b>4</b> (3): <span class="nowrap">184–</span>195. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://doi.org/10.1145%2F367177.367199">10.1145/367177.367199</a></span>. <a href="S2CID_(identifier)" class="mw-redirect" title="S2CID (identifier)">S2CID</a> <a rel="nofollow" class="external text" href="https://api.semanticscholar.org/CorpusID:1489409">1489409</a><span class="reference-accessdate">. Retrieved <span class="nowrap">2018-09-22</span></span>.</cite></span>
</li>
<li id="cite_note-5"><span class="mw-cite-backlink"><b><a href="#cite_ref-5">^</a></b></span> <span class="reference-text"><cite id="CITEREFDhurjatiKowshikAdveLattner2003" class="citation conference cs1">Dhurjati, Dinakar; Kowshik, Sumant; Adve, Vikram; Lattner, Chris (1 January 2003). <a rel="nofollow" class="external text" href="http://llvm.org/pubs/2003-05-05-LCTES03-CodeSafety.pdf">"Memory safety without runtime checks or garbage collection"</a> <span class="cs1-format">(PDF)</span>. <i>Proceedings of the 2003 ACM SIGPLAN conference on Language, compiler, and tool for embedded systems</i>. Vol. 38. ACM. pp. <span class="nowrap">69–</span>80. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1145%2F780732.780743">10.1145/780732.780743</a>. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <bdi>1581136471</bdi>. <a href="S2CID_(identifier)" class="mw-redirect" title="S2CID (identifier)">S2CID</a> <a rel="nofollow" class="external text" href="https://api.semanticscholar.org/CorpusID:1459540">1459540</a><span class="reference-accessdate">. Retrieved <span class="nowrap">2018-09-22</span></span>.</cite></span>
</li>
<li id="cite_note-6"><span class="mw-cite-backlink"><b><a href="#cite_ref-6">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://www.cprogramming.com/debugging/segfaults.html">"Debugging Segmentation Faults and Pointer Problems - Cprogramming.com"</a>. <i>www.cprogramming.com</i><span class="reference-accessdate">. Retrieved <span class="nowrap">2021-02-03</span></span>.</cite></span>
</li>
<li id="cite_note-7"><span class="mw-cite-backlink"><b><a href="#cite_ref-7">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://feepingcreature.github.io/handling.html">"Cleanly recovering from Segfaults under Windows and Linux (32-bit, x86)"</a><span class="reference-accessdate">. Retrieved <span class="nowrap">2020-08-23</span></span>.</cite></span>
</li>
<li id="cite_note-8"><span class="mw-cite-backlink"><b><a href="#cite_ref-8">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://github.com/vmarkovtsev/DeathHandler">"Implementation of the SIGSEGV/SIGABRT handler which prints the debug stack trace"</a>. <i><a href="GitHub" title="GitHub">GitHub</a></i><span class="reference-accessdate">. Retrieved <span class="nowrap">2020-08-23</span></span>.</cite></span>
</li>
<li id="cite_note-9"><span class="mw-cite-backlink"><b><a href="#cite_ref-9">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://stackoverflow.com/questions/17671869/how-to-identify-read-or-write-operations-of-page-fault-when-using-sigaction-hand">"How to identify read or write operations of page fault when using sigaction handler on SIGSEGV?(LINUX)"</a><span class="reference-accessdate">. Retrieved <span class="nowrap">2020-08-23</span></span>.</cite></span>
</li>
<li id="cite_note-10"><span class="mw-cite-backlink"><b><a href="#cite_ref-10">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://devarea.com/linux-writing-fault-handlers/">"LINUX – WRITING FAULT HANDLERS"</a>. 12 November 2017<span class="reference-accessdate">. Retrieved <span class="nowrap">2020-08-23</span></span>.</cite></span>
</li>
<li id="cite_note-11"><span class="mw-cite-backlink"><b><a href="#cite_ref-11">^</a></b></span> <span class="reference-text"><cite class="citation book cs1">"6.1.4 String literals". <i>ISO/IEC 9899:1990 - Programming languages -- C</i>.</cite></span>
</li>
<li id="cite_note-12"><span class="mw-cite-backlink"><b><a href="#cite_ref-12">^</a></b></span> <span class="reference-text"><cite class="citation book cs1">"6.4.5 String literals". <i>ISO/IEC 9899:1999 - Programming languages -- C</i>.</cite></span>
</li>
<li id="cite_note-13"><span class="mw-cite-backlink"><b><a href="#cite_ref-13">^</a></b></span> <span class="reference-text"><cite class="citation book cs1">"6.4.5 String literals". <a rel="nofollow" class="external text" href="http://www.iso-9899.info/n1570.html#6.4.5p6"><i>ISO/IEC 9899:2011 - Programming languages -- C</i></a>.</cite></span>
</li>
<li id="cite_note-14"><span class="mw-cite-backlink"><b><a href="#cite_ref-14">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://stackoverflow.com/questions/2685413/what-is-the-difference-between-a-segmentation-fault-and-a-stack-overflow/2685434#2685434">"What is the difference between a segmentation fault and a stack overflow?"</a>. <i>Stack Overflow</i><span class="reference-accessdate">. Retrieved <span class="nowrap">2023-11-11</span></span>.</cite></span>
</li>
</ol></div></div>
<div class="mw-heading mw-heading2"><h2 id="External_links">External links</h2></div>
<style data-mw-deduplicate="TemplateStyles:r1290876196">
/* start https://en.wikipedia.org/ */
.mw-parser-output .side-box{margin:4px 0;box-sizing:border-box;border:1px solid #aaa;font-size:88%;line-height:1.25em;background-color:var(--background-color-interactive-subtle,#f8f9fa);display:flow-root}.mw-parser-output .infobox .side-box{font-size:100%}.mw-parser-output .side-box-abovebelow,.mw-parser-output .side-box-text{padding:0.25em 0.9em}.mw-parser-output .side-box-image{padding:2px 0 2px 0.9em;text-align:center}.mw-parser-output .side-box-imageright{padding:2px 0.9em 2px 0;text-align:center}@media(min-width:500px){.mw-parser-output .side-box-flex{display:flex;align-items:center}.mw-parser-output .side-box-text{flex:1;min-width:0}}@media(min-width:720px){.mw-parser-output .side-box{width:238px}.mw-parser-output .side-box-right{clear:right;float:right;margin-left:1em}.mw-parser-output .side-box-left{margin-right:1em}}
/* end https://en.wikipedia.org/ */
</style><style data-mw-deduplicate="TemplateStyles:r1237033735">
/* start https://en.wikipedia.org/ */
@media print{body.ns-0 .mw-parser-output .sistersitebox{display:none!important}}@media screen{html.skin-theme-clientpref-night .mw-parser-output .sistersitebox img[src*="Wiktionary-logo-en-v2.svg"]{background-color:white}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .sistersitebox img[src*="Wiktionary-logo-en-v2.svg"]{background-color:white}}
/* end https://en.wikipedia.org/ */
</style><div class="side-box side-box-right sistersitebox"><style data-mw-deduplicate="TemplateStyles:r1126788409">
/* start https://en.wikipedia.org/ */
.mw-parser-output .plainlist ol,.mw-parser-output .plainlist ul{line-height:inherit;list-style:none;margin:0;padding:0}.mw-parser-output .plainlist ol li,.mw-parser-output .plainlist ul li{margin-bottom:0}
/* end https://en.wikipedia.org/ */
</style>
<div class="side-box-flex">
<div class="side-box-image"><span class="noviewer" typeof="mw:File"></span></div>
<div class="side-box-text plainlist">Look up <i><b><a href="https://en.wiktionary.org/wiki/Special:Search/segmentation_fault" class="extiw external" title="wiktionary:Special:Search/segmentation fault">segmentation fault</a></b></i> in Wiktionary, the free dictionary.</div></div>
</div>
<ul><li><a rel="nofollow" class="external text" href="https://www.encious.com/process">Process: focus boundary and segmentation fault</a></li>
<li><a rel="nofollow" class="external text" href="http://www.faqs.org/qa/qa-673.html">A FAQ: User contributed answers regarding the definition of a segmentation fault</a></li>
<li><a rel="nofollow" class="external text" href="http://c-faq.com/null/null1.html">A "null pointer" explained</a></li>
<li><a rel="nofollow" class="external text" href="http://c-faq.com/null/varieties.html">Answer to: NULL is guaranteed to be 0, but the null pointer is not?</a></li>
<li><a rel="nofollow" class="external text" href="http://www.opengroup.org/onlinepubs/009695399/basedefs/signal.h.html">The Open Group Base Specifications Issue 6 signal.h</a></li></ul>
<div class="navbox-styles"><style data-mw-deduplicate="TemplateStyles:r1129693374">
/* start https://en.wikipedia.org/ */
.mw-parser-output .hlist dl,.mw-parser-output .hlist ol,.mw-parser-output .hlist ul{margin:0;padding:0}.mw-parser-output .hlist dd,.mw-parser-output .hlist dt,.mw-parser-output .hlist li{margin:0;display:inline}.mw-parser-output .hlist.inline,.mw-parser-output .hlist.inline dl,.mw-parser-output .hlist.inline ol,.mw-parser-output .hlist.inline ul,.mw-parser-output .hlist dl dl,.mw-parser-output .hlist dl ol,.mw-parser-output .hlist dl ul,.mw-parser-output .hlist ol dl,.mw-parser-output .hlist ol ol,.mw-parser-output .hlist ol ul,.mw-parser-output .hlist ul dl,.mw-parser-output .hlist ul ol,.mw-parser-output .hlist ul ul{display:inline}.mw-parser-output .hlist .mw-empty-li{display:none}.mw-parser-output .hlist dt::after{content:": "}.mw-parser-output .hlist dd::after,.mw-parser-output .hlist li::after{content:" · ";font-weight:bold}.mw-parser-output .hlist dd:last-child::after,.mw-parser-output .hlist dt:last-child::after,.mw-parser-output .hlist li:last-child::after{content:none}.mw-parser-output .hlist dd dd:first-child::before,.mw-parser-output .hlist dd dt:first-child::before,.mw-parser-output .hlist dd li:first-child::before,.mw-parser-output .hlist dt dd:first-child::before,.mw-parser-output .hlist dt dt:first-child::before,.mw-parser-output .hlist dt li:first-child::before,.mw-parser-output .hlist li dd:first-child::before,.mw-parser-output .hlist li dt:first-child::before,.mw-parser-output .hlist li li:first-child::before{content:" (";font-weight:normal}.mw-parser-output .hlist dd dd:last-child::after,.mw-parser-output .hlist dd dt:last-child::after,.mw-parser-output .hlist dd li:last-child::after,.mw-parser-output .hlist dt dd:last-child::after,.mw-parser-output .hlist dt dt:last-child::after,.mw-parser-output .hlist dt li:last-child::after,.mw-parser-output .hlist li dd:last-child::after,.mw-parser-output .hlist li dt:last-child::after,.mw-parser-output .hlist li li:last-child::after{content:")";font-weight:normal}.mw-parser-output .hlist ol{counter-reset:listitem}.mw-parser-output .hlist ol>li{counter-increment:listitem}.mw-parser-output .hlist ol>li::before{content:" "counter(listitem)"\a0 "}.mw-parser-output .hlist dd ol>li:first-child::before,.mw-parser-output .hlist dt ol>li:first-child::before,.mw-parser-output .hlist li ol>li:first-child::before{content:" ("counter(listitem)"\a0 "}
/* end https://en.wikipedia.org/ */
</style><style data-mw-deduplicate="TemplateStyles:r1236075235">
/* start https://en.wikipedia.org/ */
.mw-parser-output .navbox{box-sizing:border-box;border:1px solid #a2a9b1;width:100%;clear:both;font-size:88%;text-align:center;padding:1px;margin:1em auto 0}.mw-parser-output .navbox .navbox{margin-top:0}.mw-parser-output .navbox+.navbox,.mw-parser-output .navbox+.navbox-styles+.navbox{margin-top:-1px}.mw-parser-output .navbox-inner,.mw-parser-output .navbox-subgroup{width:100%}.mw-parser-output .navbox-group,.mw-parser-output .navbox-title,.mw-parser-output .navbox-abovebelow{padding:0.25em 1em;line-height:1.5em;text-align:center}.mw-parser-output .navbox-group{white-space:nowrap;text-align:right}.mw-parser-output .navbox,.mw-parser-output .navbox-subgroup{background-color:#fdfdfd}.mw-parser-output .navbox-list{line-height:1.5em;border-color:#fdfdfd}.mw-parser-output .navbox-list-with-group{text-align:left;border-left-width:2px;border-left-style:solid}.mw-parser-output tr+tr>.navbox-abovebelow,.mw-parser-output tr+tr>.navbox-group,.mw-parser-output tr+tr>.navbox-image,.mw-parser-output tr+tr>.navbox-list{border-top:2px solid #fdfdfd}.mw-parser-output .navbox-title{background-color:#ccf}.mw-parser-output .navbox-abovebelow,.mw-parser-output .navbox-group,.mw-parser-output .navbox-subgroup .navbox-title{background-color:#ddf}.mw-parser-output .navbox-subgroup .navbox-group,.mw-parser-output .navbox-subgroup .navbox-abovebelow{background-color:#e6e6ff}.mw-parser-output .navbox-even{background-color:#f7f7f7}.mw-parser-output .navbox-odd{background-color:transparent}.mw-parser-output .navbox .hlist td dl,.mw-parser-output .navbox .hlist td ol,.mw-parser-output .navbox .hlist td ul,.mw-parser-output .navbox td.hlist dl,.mw-parser-output .navbox td.hlist ol,.mw-parser-output .navbox td.hlist ul{padding:0.125em 0}.mw-parser-output .navbox .navbar{display:block;font-size:100%}.mw-parser-output .navbox-title .navbar{float:left;text-align:left;margin-right:0.5em}body.skin--responsive .mw-parser-output .navbox-image img{max-width:none!important}@media print{body.ns-0 .mw-parser-output .navbox{display:none!important}}
/* end https://en.wikipedia.org/ */
</style></div><div role="navigation" class="navbox" aria-labelledby="Operating_systems310" style="padding:3px"><table class="nowraplinks mw-collapsible autocollapse navbox-inner" style="border-spacing:0;background:transparent;color:inherit"><tbody><tr><th scope="col" class="navbox-title" colspan="2"><style data-mw-deduplicate="TemplateStyles:r1239400231">
/* start https://en.wikipedia.org/ */
.mw-parser-output .navbar{display:inline;font-size:88%;font-weight:normal}.mw-parser-output .navbar-collapse{float:left;text-align:left}.mw-parser-output .navbar-boxtext{word-spacing:0}.mw-parser-output .navbar ul{display:inline-block;white-space:nowrap;line-height:inherit}.mw-parser-output .navbar-brackets::before{margin-right:-0.125em;content:"[ "}.mw-parser-output .navbar-brackets::after{margin-left:-0.125em;content:" ]"}.mw-parser-output .navbar li{word-spacing:-0.125em}.mw-parser-output .navbar a>span,.mw-parser-output .navbar a>abbr{text-decoration:inherit}.mw-parser-output .navbar-mini abbr{font-variant:small-caps;border-bottom:none;text-decoration:none;cursor:inherit}.mw-parser-output .navbar-ct-full{font-size:114%;margin:0 7em}.mw-parser-output .navbar-ct-mini{font-size:114%;margin:0 4em}html.skin-theme-clientpref-night .mw-parser-output .navbar li a abbr{color:var(--color-base)!important}@media(prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .navbar li a abbr{color:var(--color-base)!important}}@media print{.mw-parser-output .navbar{display:none!important}}
/* end https://en.wikipedia.org/ */
</style><div id="Operating_systems310" style="font-size:114%;margin:0 4em"><a href="Operating_system" title="Operating system">Operating systems</a></div></th></tr><tr><th scope="row" class="navbox-group" style="width:1%">General</th><td class="navbox-list-with-group navbox-list navbox-odd hlist" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Comparison_of_operating_systems" title="Comparison of operating systems">Comparison</a></li>
<li><a href="Forensic_software_engineering" title="Forensic software engineering">Forensic engineering</a></li>
<li><a href="History_of_operating_systems" title="History of operating systems">History</a></li>
<li><a href="List_of_operating_systems" title="List of operating systems">List</a></li>
<li><a href="Timeline_of_operating_systems" title="Timeline of operating systems">Timeline</a></li>
<li><a href="Usage_share_of_operating_systems" title="Usage share of operating systems">Usage share</a></li>
<li><a href="Comparison_of_user_features_of_operating_systems" title="Comparison of user features of operating systems">User features comparison</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%">Variants</th><td class="navbox-list-with-group navbox-list navbox-even hlist" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Disk_operating_system" title="Disk operating system">Disk operating system</a></li>
<li><a href="Distributed_operating_system" title="Distributed operating system">Distributed operating system</a></li>
<li><a href="Embedded_operating_system" title="Embedded operating system">Embedded operating system</a></li>
<li><a href="Hobbyist_operating_system" title="Hobbyist operating system">Hobbyist operating system</a></li>
<li><a href="Just_enough_operating_system" title="Just enough operating system">Just enough operating system</a></li>
<li><a href="Mobile_operating_system" title="Mobile operating system">Mobile operating system</a></li>
<li><a href="Network_operating_system" title="Network operating system">Network operating system</a></li>
<li><a href="Object-oriented_operating_system" title="Object-oriented operating system">Object-oriented operating system</a></li>
<li><a href="Real-time_operating_system" title="Real-time operating system">Real-time operating system</a></li>
<li><a href="Supercomputer_operating_system" title="Supercomputer operating system">Supercomputer operating system</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Kernel_(operating_system)" title="Kernel (operating system)">Kernel</a></th><td class="navbox-list-with-group navbox-list navbox-odd hlist" style="width:100%;padding:0"><div style="padding:0 0.25em"></div><table class="nowraplinks navbox-subgroup" style="border-spacing:0"><tbody><tr><th scope="row" class="navbox-group" style="width:6em"><a href="Computer_architecture" title="Computer architecture">Architectures</a></th><td class="navbox-list-with-group navbox-list navbox-odd" style="padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Exokernel" title="Exokernel">Exokernel</a></li>
<li><a href="Hybrid_kernel" title="Hybrid kernel">Hybrid</a></li>
<li><a href="Microkernel" title="Microkernel">Microkernel</a></li>
<li><a href="Monolithic_kernel" title="Monolithic kernel">Monolithic</a></li>
<li><a href="Multikernel" title="Multikernel">Multikernel</a></li>
<li><a href="Vkernel" title="Vkernel">vkernel</a></li>
<li><a href="Rump_kernel" title="Rump kernel">Rump kernel</a></li>
<li><a href="Unikernel" title="Unikernel">Unikernel</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:6em">Components</th><td class="navbox-list-with-group navbox-list navbox-even" style="padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Device_driver" title="Device driver">Device driver</a></li>
<li><a href="Loadable_kernel_module" title="Loadable kernel module">Loadable kernel module</a></li>
<li><a href="User_space_and_kernel_space" title="User space and kernel space">User space and kernel space</a></li></ul>
</div></td></tr></tbody></table><div></div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Process_management_(computing)" title="Process management (computing)">Process management</a></th><td class="navbox-list-with-group navbox-list navbox-odd hlist" style="width:100%;padding:0"><div style="padding:0 0.25em"></div><table class="nowraplinks navbox-subgroup" style="border-spacing:0"><tbody><tr><th scope="row" class="navbox-group" style="width:6em">Concepts</th><td class="navbox-list-with-group navbox-list navbox-odd" style="padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Computer_multitasking" title="Computer multitasking">Computer multitasking</a> (<a href="Cooperative_multitasking" title="Cooperative multitasking">Cooperative</a>, <a href="Preemption_(computing)" title="Preemption (computing)">Preemptive</a>)</li>
<li><a href="Context_switch" title="Context switch">Context switch</a></li>
<li><a href="Interrupt" title="Interrupt">Interrupt</a></li>
<li><a href="Inter-process_communication" title="Inter-process communication">IPC</a></li>
<li><a href="Process_(computing)" title="Process (computing)">Process</a></li>
<li><a href="Process_control_block" title="Process control block">Process control block</a></li>
<li><a href="Real-time_operating_system" title="Real-time operating system">Real-time</a></li>
<li><a href="Thread_(computing)" title="Thread (computing)">Thread</a></li>
<li><a href="Time-sharing" title="Time-sharing">Time-sharing</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:6em"><a href="Scheduling_(computing)" title="Scheduling (computing)">Scheduling<br>algorithms</a></th><td class="navbox-list-with-group navbox-list navbox-even" style="padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Fixed-priority_pre-emptive_scheduling" title="Fixed-priority pre-emptive scheduling">Fixed-priority preemptive</a></li>
<li><a href="Multilevel_feedback_queue" title="Multilevel feedback queue">Multilevel feedback queue</a></li>
<li><a href="Round-robin_scheduling" title="Round-robin scheduling">Round-robin</a></li>
<li><a href="Shortest_job_next" title="Shortest job next">Shortest job next</a></li></ul>
</div></td></tr></tbody></table><div></div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Memory_management_(operating_systems)" title="Memory management (operating systems)">Memory management</a>,<br><a href="System_resource" title="System resource">resource</a> protection</th><td class="navbox-list-with-group navbox-list navbox-odd hlist" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Bus_error" title="Bus error">Bus error</a></li>
<li><a href="General_protection_fault" title="General protection fault">General protection fault</a></li>
<li><a href="Memory_paging" title="Memory paging">Memory paging</a></li>
<li><a href="Memory_protection" title="Memory protection">Memory protection</a></li>
<li><a href="Protection_ring" title="Protection ring">Protection ring</a></li>
<li><a href="Virtual_memory" title="Virtual memory">Virtual memory</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Non-volatile_memory" title="Non-volatile memory">Storage</a> access,<br><a href="File_system" title="File system">file systems</a></th><td class="navbox-list-with-group navbox-list navbox-even hlist" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Booting#BOOT-LOADER" title="Booting">Boot loader</a></li>
<li><a href="Defragmentation" title="Defragmentation">Defragmentation</a></li>
<li><a href="Device_file" title="Device file">Device file</a></li>
<li><a href="File_attribute" title="File attribute">File attribute</a></li>
<li><a href="Inode" title="Inode">Inode</a></li>
<li><a href="Journaling_file_system" title="Journaling file system">Journal</a></li>
<li><a href="Disk_partitioning" title="Disk partitioning">Partition</a></li>
<li><a href="Virtual_file_system" title="Virtual file system">Virtual file system</a></li>
<li><a href="Virtual_tape_library" title="Virtual tape library">Virtual tape library</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%">Supporting concepts</th><td class="navbox-list-with-group navbox-list navbox-odd hlist" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="API" title="API">API</a></li>
<li><a href="Computer_network" title="Computer network">Computer network</a></li>
<li><a href="Hardware_abstraction" title="Hardware abstraction">HAL</a></li>
<li><a href="Live_CD" title="Live CD">Live CD</a></li>
<li><a href="Live_USB" title="Live USB">Live USB</a></li>
<li><a href="Shell_(computing)" title="Shell (computing)">Shell</a>
<ul><li><a href="Command-line_interface" title="Command-line interface">CLI</a></li>
<li><a href="User_interface" title="User interface">User interface</a></li></ul></li>
<li><a href="Preboot_Execution_Environment" title="Preboot Execution Environment">PXE</a></li></ul>
</div></td></tr></tbody></table></div>
<div class="navbox-styles"></div><div role="navigation" class="navbox" aria-labelledby="Error_messages90" style="padding:3px"><table class="nowraplinks mw-collapsible autocollapse navbox-inner" style="border-spacing:0;background:transparent;color:inherit"><tbody><tr><th scope="col" class="navbox-title" colspan="2"><div id="Error_messages90" style="font-size:114%;margin:0 4em"><a href="Error_message" title="Error message">Error messages</a></div></th></tr><tr><th scope="row" class="navbox-group" style="width:1%">System failure</th><td class="navbox-list-with-group navbox-list navbox-odd hlist" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Bomb_(icon)" title="Bomb (icon)">Bomb icon</a></li>
<li><a href="Fatal_system_error" title="Fatal system error">Fatal system error</a></li>
<li><a href="Guru_Meditation" title="Guru Meditation">Guru Meditation</a></li>
<li><a href="Kernel_panic" title="Kernel panic">Kernel panic</a></li>
<li><a href="Linux_kernel_oops" title="Linux kernel oops">Linux kernel oops</a></li>
<li><a href="Xbox_360_technical_problems" title="Xbox 360 technical problems">Red Ring of Death</a></li>
<li><a href="Macintosh_startup#Sad_Mac" title="Macintosh startup">Sad Mac</a></li>
<li><a href="Screen_of_death" class="mw-redirect" title="Screen of death">Screen of death</a>
<ul><li><a href="Blue_screen_of_death" title="Blue screen of death">Blue</a></li>
<li><a href="Black_screen_of_death" title="Black screen of death">Black</a></li></ul></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%">Application failure</th><td class="navbox-list-with-group navbox-list navbox-even hlist" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Abnormal_end" class="mw-redirect" title="Abnormal end">ABEND</a></li>
<li><a href="Fatal_exception_error" title="Fatal exception error">Fatal exception error</a></li>
</ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%">Device and data errors</th><td class="navbox-list-with-group navbox-list navbox-odd hlist" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="HTTP_402" class="mw-redirect" title="HTTP 402">HTTP 402</a></li>
<li><a href="HTTP_403" title="HTTP 403">HTTP 403</a></li>
<li><a href="HTTP_404" title="HTTP 404">HTTP 404</a></li>
<li><a href="HTTP_500" class="mw-redirect" title="HTTP 500">HTTP 500</a></li>
<li><a href="Lp0_on_fire" title="Lp0 on fire">lp0 on fire</a></li>
<li><a href="Not_a_typewriter" title="Not a typewriter">Not a typewriter</a></li>
<li><a href="PC_LOAD_LETTER" title="PC LOAD LETTER">PC LOAD LETTER</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%">Other</th><td class="navbox-list-with-group navbox-list navbox-even hlist" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Abort%2C_Retry%2C_Fail%3F" title="Abort, Retry, Fail?">Abort, Retry, Fail?</a></li>
<li><a href="Bad_command_or_file_name" title="Bad command or file name">Bad command or file name</a></li>
<li><a href="Halt_and_Catch_Fire_(computing)" title="Halt and Catch Fire (computing)">Halt and Catch Fire</a></li>
<li><a href="Hyper_Text_Coffee_Pot_Control_Protocol" title="Hyper Text Coffee Pot Control Protocol">HTTP 418</a></li>
<li><a href="Out_of_memory" title="Out of memory">Out of memory</a></li>
<li><a href="Does_not_compute" title="Does not compute">Does not compute</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%">Lists</th><td class="navbox-list-with-group navbox-list navbox-odd hlist" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="List_of_HTTP_status_codes" title="List of HTTP status codes">List of HTTP status codes</a></li>
<li><a href="List_of_FTP_server_return_codes" title="List of FTP server return codes">List of FTP server return codes</a></li>
<li><a href="List_of_SMTP_server_return_codes" title="List of SMTP server return codes">List of SMTP server return codes</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%">Related</th><td class="navbox-list-with-group navbox-list navbox-even hlist" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Spinning_pinwheel" title="Spinning pinwheel">Spinning pinwheel</a></li>
<li><a href="Windows_wait_cursor" title="Windows wait cursor">Windows wait cursor</a></li>
<li><a href="2024_CrowdStrike-related_IT_outages" title="2024 CrowdStrike-related IT outages">2024 CrowdStrike-related IT outages</a></li></ul>
</div></td></tr></tbody></table></div></div><!--htdig_noindex--><div><div class="zim-footer">
This article is issued from <a class="external text" title="Last edited on 2025-07-22" href="https://en.wikipedia.org/wiki/?title=Segmentation_fault&oldid=1301977079">Wikipedia</a>. The text is available under <a class="external text" href="https://creativecommons.org/licenses/by-sa/4.0/deed.en">Creative Commons Attribution-Share Alike 4.0</a> unless otherwise noted. Additional terms may apply for the media files.
</div>
</div><!--/htdig_noindex--></div>
</div>
</main>
</div>
</div>
</div>
</body></html>